
#pragma once

#include "TCHAR.H"
#include "Stl/STLvector.h"
#include "HrkNode.h"
#include "HrkMesh.h"
#include "HrkAnim.h"
#include "tinyxml/tinyxml.h"
#include "SceneManagement/renderableobject.h"
#include "ResourceManagement/GLmaterial.h"
#include "Renderer/GLShader.h"

class CHrkModel:public IRenderable
{
public:
	CHrkNode* m_root_node;

	STLvector<CHrkNode*> m_bone_list;
	STLvector<CHrkMesh*> m_mesh_list;
	STLvector<GLmaterial*> m_mat_list;

	static ShaderPack  m_skinProgram;

public:
	CHrkModel();
	~CHrkModel();

	virtual void Update();
	virtual void Draw();

	void DrawSkinMeshGPU();
	void DrawSkinMeshCPU();

	int FindBoneIndex( const TCHAR* name );
	bool LoadFile( const TCHAR* filename );
	void ParseMaterial( TiXmlElement* root );
	GLmaterial* FindMaterial( const TCHAR* name );
	void ParseNode( TiXmlElement* elem,CHrkNode* node );
	void CollectBoneList( CHrkNode* node );
	void CollectMeshList( CHrkNode* node );
	void PostLoadFile();
};